public class Test2 {
    private static Object lock = new Object() ;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
           for (int i = 0; i < 10; i++) {
               synchronized(lock){
                   System.out.print("A");
               }
               try {
                   Thread.sleep(3000);
               } catch (InterruptedException e) {
                 e.printStackTrace();
               }
           }
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 10; i++) {
                synchronized(lock){
                   System.out.print("B");
               }
               try {
                   Thread.sleep(2000);
               } catch (InterruptedException e) {
                 e.printStackTrace();
               }
            }
        });
        Thread t3 = new Thread(()->{
                for (int i = 0; i < 10; i++) {
                    synchronized(lock){
                        System.out.print("C");
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
        });
        t1.start();
        t2.start();
        t3.start();


    }
}
